package app.caihan.wanandroid.model.db.converters

import androidx.room.TypeConverter
import app.caihan.wanandroid.model.bean.Tag
import com.blankj.utilcode.util.GsonUtils
import com.google.gson.reflect.TypeToken

/**
 *
 *
 * @author Seven-C
 * @date 2020/8/20
 */
open class TagsTypeConverters {

    @TypeConverter
    fun stringToTags(json: String): List<Tag> {
        val type = object : TypeToken<List<Tag>>() {}.type
        return GsonUtils.fromJson(json, type)
    }

    @TypeConverter
    fun tagsToString(data: List<Tag>): String = GsonUtils.toJson(data)
}